home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.011 < prev    next >
Encoding:
Text File  |  1988-12-16  |  8.5 KB  |  153 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Apple IIGS
  8. #11:    Ensoniq DOC Swap-Mode Anomaly
  9.  
  10. Revised by:    Jim Mensch                                       November 1988
  11. Written by:    Jim Merritt                                         April 1987
  12.  
  13. Under certain conditions, the IIGS Ensoniq Digital Oscillator Chip (DOC) 
  14. inserts a spurious zero-crossing byte into the output sample stream.  The 
  15. output sample waveform may mask the anomaly, but if it does not, the user may 
  16. hear intermittent clicks or even a more pervasive "static."  This Technical 
  17. Note discusses the situations in which the DOC produces this spurious zero 
  18. crossing, as well as strategies to avoid or mask this undesirable behavior.
  19. _____________________________________________________________________________
  20.  
  21.  
  22. Background
  23.  
  24. The Ensoniq DOC in the Apple IIGS is actually a microprocessor dedicated to 
  25. producing sound.  Like a time-sharing computer, the DOC continually scans 
  26. through its array of sound oscillators, proceeding from lower-numbered 
  27. oscillators to higher-numbered ones, and updates the signal output level of 
  28. each active one to match that indicated by the oscillator's current sample 
  29. byte.
  30.  
  31. An oscillator can operate in any one of several functional modes, as described 
  32. in the Apple IIGS Hardware Reference.  Here, however, we are concerned only 
  33. with swap mode, where two consecutive oscillators are considered as a single 
  34. generator.  The low-numbered oscillator in the pair is always even.  For 
  35. example, the pairs of oscillators 0 & 1, 2 & 3, ... , 12 & 13, and 14 & 15 
  36. constitute generators.  The IIGS Sound Tool Set - the FFStartSound call in 
  37. particular - configures the oscillators it uses to operate in swap mode.  In 
  38. swap mode, the even-numbered oscillator plays its waveform first, halts its 
  39. own playback, then starts its partner which also plays its waveform, halts its 
  40. own playback upon exhausting its waveform, and restarts the even-numbered 
  41. oscillator.  At any time between the start of any particular FFStartSound call 
  42. and the time the oscillator finishes playing a wave, the Sound Tool Set 
  43. interrupt handler may be busy transferring waveform information from the IIGS 
  44. main RAM to the dormant oscillator's buffer in DOC RAM.  Since one oscillator 
  45. is producing sound while the Sound Tool Set interrupt handler is transferring 
  46. waveform information to the other oscillator, you can use a generator pair to 
  47. produce continuous sound of arbitrary length, and you are limited only by the 
  48. amount of memory you can devote to the waveform in the main RAM.
  49.  
  50. Each oscillator draws its output samples from a dedicated buffer in DOC RAM, 
  51. the size and location of which are specified by parameters to the FFStartSound 
  52. call.  The maximum size for an oscillator buffer is 32K, but since buffers may 
  53. neither coincide nor overlap, the practical maximum may be lower when more 
  54. than one generator is active.  For instance, if four generators (eight paired 
  55. oscillators) are active simultaneously, the maximum buffer size is 8K, since 
  56. eight non-overlapping buffers of 8K each would occupy the entire 64K available 
  57. in the DOC RAM.
  58.  
  59.  
  60. The Problem
  61.  
  62. Whenever a swap occurs from a higher-numbered oscillator to a lower-numbered 
  63. one, the output signal from the corresponding generator temporarily falls to 
  64. the zero-crossing level (silence); this anomaly does not occur during swaps 
  65. from lower-numbered oscillators to higher-numbered ones.  The spurious level 
  66. change lasts no longer than a single sample period, at which time the 
  67. interrupted waveform resumes.  However, even this tiny glitch in the output 
  68. can be audible as a pop or click;  the further away the waveform is from the 
  69. zero crossing when the swap interrupts it, the louder the ear will perceive 
  70. the pop or click.  When high-to-low swaps occur with great frequency, the pops 
  71. and clicks happen so often that they are perceived as gentle, but pervasive, 
  72. static.
  73.  
  74.  
  75. Several Workarounds
  76.  
  77. There is no ideal solution to the problem of signal interruption in swap mode.  
  78. This problem is an anomaly of the DOC design, which may or may not be 
  79. addressed in later versions of the chip.  However, we have found three general 
  80. strategies for mitigating the audible damage to the output waveform caused by 
  81. the chip's undesirable behavior.
  82.  
  83. Minimize Oscillator Swaps per Unit Time
  84.  
  85. The more often swaps from high-numbered oscillators to low-numbered ones 
  86. occur, the more obtrusive the brief signal interruptions will seem.  To 
  87. minimize the interruptions, you must make the oscillators play for a longer 
  88. period of time before swapping to their partners.  This means that they must 
  89. play at slower output sample rates, use larger buffers in DOC RAM, or use the 
  90. two in tandem.  Commensurate with the number of active generators you wish to 
  91. use and the level of output signal fidelity that you desire, always specify 
  92. the largest DOC buffer size and the lowest output sample rate that you 
  93. possibly can.  Remember that a large number of active generators implies a 
  94. very small maximum buffer size for any particular oscillator, so you should 
  95. always try to minimize the number of generators that are active at any one 
  96. time.  As a rough benchmark, the clicks of signal interruption begin to blend 
  97. into highly audible static when you specify buffers smaller than 8K for use at 
  98. the maximum-fidelity output sample rate of about 26 kHz.  (Note:  The DOC 
  99. supports greater sample rates, but these rates are limited by the output 
  100. filtering on the IIGS which permits no greater signal fidelity than that 
  101. possible using the 26 kHz rate.)  Our figures suggest that output fidelity 
  102. must suffer, or signal noise must increase, when more than four generators 
  103. (eight oscillators in swap mode) are operating simultaneously.
  104.  
  105. Avoid Silent or Quiet Passages
  106.  
  107. The signal content of your waveform can hide the additional noise caused by 
  108. the "swap-mode anomaly."  The more complex and louder a waveform, the less 
  109. your ear will perceive the brief interruption that occurs whenever a higher-
  110. numbered oscillator swaps to a lower-numbered one; pop and rock music is far 
  111. less susceptible to this problem than classical, folk, or jazz pieces, which 
  112. typically include many quiet passages.  In addition, a signal that naturally 
  113. contains a large amount of "pink noise," such as recordings of rainstorms or 
  114. the surf at the beach, can mask the anomalous noise altogether.
  115.  
  116. Arrange for Swaps to Occur at or Near Zero Crossings
  117.  
  118. If the high-to-low swap occurs at a time when the normal output signal level 
  119. sits at or near the zero crossing, the swap will cause little or no audible 
  120. damage to the waveform.  When reproducing arbitrary sampled sound, it is 
  121. almost impossible to insure that the output signal level is near the zero 
  122. crossing.  However, when constructing long waveforms for playback, you may be 
  123. able to sidestep the chip's anomalous behavior by ensuring that the waveform 
  124. values lie at or near $80 at the end of every waveform segment, where a 
  125. waveform segment spans twice the length of one oscillator buffer.  For 
  126. example, if you specify a buffer size of 4K, make sure that your constructed 
  127. waveform crosses the baseline after every 8,192 samples, and for 16K buffers, 
  128. make sure that the waveform makes a zero crossing after every 32K.
  129.  
  130. The length of the waveform segment should be twice the buffer length only if 
  131. you are going to reproduce the waveform exactly once per FFStartSound call.  
  132. It may be necessary to shorten the length of the waveform segment to exactly 
  133. the specified DOC buffer length if you use the nextwave_start parameter in the 
  134. FFStartSound parameter block to invoke automatic looping of the waveform.  In 
  135. other words, you may need to arrange for twice as many zero crossings in your 
  136. constructed waveform in the looping case as you would under normal 
  137. circumstances since subsequent repetitions of the waveform during the single 
  138. FFStartSound call may begin with either the even or odd oscillator, depending 
  139. upon which member of the pair was active when the previous repetition ended.  
  140. If the playback of a waveform starts with the odd oscillator, then the odd-to-
  141. even swaps will occur at different points in the waveform than they would when 
  142. the playback starts with the even oscillator.
  143.  
  144. Also note that the use of larger buffers causes a progressively longer 
  145. disabling of interrupts while the Sound Tool Set moves the waveform into the 
  146. DOC RAM.
  147.  
  148.  
  149. Further Reference
  150. o    Apple IIGS Toolbox Reference, Volume 2
  151. o    Apple IIGS Hardware Reference
  152.  
  153.